package com.llgz.hotelmanageapi.controller;

import com.llgz.hotelmanageapi.common.CommonResult;
import com.llgz.hotelmanageapi.service.impl.IndexServiceImpl;
import com.llgz.hotelmanageapi.service.impl.OrderPersonServiceImpl;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LinHj
 * @date 2021/7/27 15:41
 **/
@RestController
@RequestMapping("/welcome")
@RequiresRoles(value = {"root", "admin", "manager", "reception"}, logical = Logical.OR)
public class indexController {
    @Autowired
    IndexServiceImpl indexService;

    @GetMapping("/getShowData")
    public CommonResult getShowData(){
        Map<String, Object> data = indexService.getData();
        return CommonResult.successResponse(data);
    }

    @GetMapping("/lastWeekIncome")
    public CommonResult lastWeekIncome(){
        List<Double> lastWeekIncome = indexService.getLastWeekIncome();
        List<Double> lastWeekAccommodationExpenses = indexService.getLastWeekAccommodationExpenses();
        HashMap<String, Object> map = new HashMap<>();
        map.put("income",lastWeekIncome);
        map.put("expenses",lastWeekAccommodationExpenses);
        return CommonResult.successResponse(map);

    }

}
